
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

class TestDb_Dao {


	
	public static void main (String[] args) {
		ArrayList arr=new ArrayList();
		ArrayList arr2=new ArrayList();
		try
		{
//			Step 1: Load the JDBC driver.
			Class.forName("com.mysql.jdbc.Driver");
//			Step 2: Establish the connection to the database.

			Connection conn = DriverManager.getConnection("jdbc:mysql://ist402.ist.psu.edu/nks125?user=nks125&password=qwert123y");

			if (conn!=null)
				System.out.println("connected!");
		
			Statement s = conn.createStatement();
			//query here
			ResultSet rs = s.executeQuery("SELECT * FROM images");
			//get query result into the Imagetable object	
			while (rs.next()){
				Imagetable img1=new Imagetable();
				img1.setImage_id(rs.getString("image_id"));
				img1.setOwner(rs.getString("owner"));
				img1.setDate(rs.getString(3));
				arr.add(img1);
			//	System.out.println(img1.date);
			}

//			report errors like "Exception in thread "main" java.lang.OutOfMemoryError: Java heap space" Not sure how much data we have	
//			ResultSet rs2 = s.executeQuery("SELECT * FROM tags");
//			//get query result into the Tagtable object	
//			while (rs2.next()){
//				Tagtable tag1=new Tagtable();
//				tag1.setImage_id(rs2.getString(1));
//				tag1.setTag_creator(rs2.getString(2));
//				tag1.setTag(rs2.getString(3));
//				arr2.add(tag1);
//				System.out.println(tag1.image_id);
//			}

		}
		catch (Exception e)
		{
			System.err.println(e.getMessage());
		}
		 
		
			
	}
}
